﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zeus.Thunder.Core;

namespace SharpTrainer.Linq
{
    class AggregateTest : ITestCase
    {
        public void Run()
        {
            int[] numbers = { 1, 2, 3, 4, 5 };

            int sum = numbers.Aggregate((total, n) => total + n); // 6
            int sum2 = numbers.Aggregate((prod, n) => prod * n);
            int sum3 = numbers.Aggregate(0, (total, n) => total + n*n);

            Console.WriteLine("sum = {0}", sum);
            Console.WriteLine("sum2 = {0}", sum2);
            Console.WriteLine("sum3 = {0}", sum3);
        }
    }
}
